﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using BusinessPlatform.Common;

namespace BusinessPlatform.Core.Database
{
    /// <summary>
    /// 数据库类型的参数
    /// </summary>
    internal class DbProviderAttribute : Attribute
    {
        private string _ProviderName;
        private string _ProviderClass;
        /// <summary>
        /// 数据驱动名称
        /// </summary>
        public string ProviderName
        {
            get { return _ProviderName; }
            set { _ProviderName = value; }
        }
        /// <summary>
        /// 数据驱动类名称
        /// </summary>
        public string ProviderClass
        {
            get { return _ProviderClass; }
            set { _ProviderClass = value; }
        }
        /// <summary>
        /// 获取值的特性
        /// </summary>
        /// <param name="EnumType"></param>
        /// <returns></returns>
        public static DbProviderAttribute GetAttribute(Enum EnumType)
        {
            Type type = EnumType.GetType();
            FieldInfo info = type.GetField(EnumType.ToString());
            if (info == null) return null;
            return info.GetCustomAttributes(typeof(DbProviderAttribute), false)[0] as DbProviderAttribute;
        }
    }
}
